if(upper(left(url,4))='FILE') then url=substr(url,pos('=',url)+1)
if(~abbrev(url,'http://',7)) then iterate x
call Play()
end
if ~found then
do
say 'No supported URLs found!!!'
exit 10
end
exit
/*** PROCEDURES ***/
Play:
if(upper(right(url,4))='.M3U' | upper(right(url,4))='.PLS') then
do
if(pos('http://',url)=1) then url=substr(url,8);port='80';crlf=d2c(13)''d2c(10);lookup=1
if(pos('/',url)>0) then do;host=substr(url,1,pos('/',url)-1);path=substr(url,pos('/',url));end
else do;host=url;path='/';end
if(pos(':',host)>0) then do;port=substr(host,pos(':',host)+1);host=substr(host,1,pos(':',host)-1);end
if ~GetHost('HOST',host) then;if(datatype(compress(host,'.'),'N')) then do;host.HOSTADDRLIST.0=host;lookup=0;end;else do;say 'Unable to lookup host!!!';iterate x;end
sock=Socket('INET','STREAM','IP');if sock<0 then do;say 'Unable to create socket!!!';iterate x;end
if(pos('http://',url)=1) then url=substr(url,8);port='80'
if(pos('/',url)>0) then do;host=substr(url,1,pos('/',url)-1);path=substr(url,pos('/',url));end
else do;host=url;path='/';end
if(pos(':',host)>0) then do;port=substr(host,pos(':',host)+1);host=substr(host,1,pos(':',host)-1);end
if(savepath~='') then
do
if(right(savepath,1)~=':' & right(savepath,1)~='/') then savepath=savepath'/'
if(path='/') then filename=mp3tmp'.mp3'
else filename=substr(path,lastpos('/',path)+1)
end
crlf=d2c(13)''d2c(10);lookup=1
if ~GetHost('HOST',host) then;if(datatype(compress(host,'.'),'N')) then do;host.HOSTADDRLIST.0=host;lookup=0;end;else do;setclip(mp3tmp,'Unable to lookup host!!!');return 10;end
sock=Socket('INET','STREAM','IP');if sock<0 then do;setclip(mp3tmp,'Unable to create socket!!!');return 10;end
if Connect(sock,'CONN')<0 then do;if(lookup) then setclip(mp3tmp,'Sorry, server is down, unable to stream data!');else setclip(mp3tmp,'Host does not exist!!!');return 10;end